<?php
  /**
   * Kontrollbase
   *
   * An open source MySQL monitoring and analytics application
   *
   * @package Kontrollbase
   * @author Matt Reid
   * @copyright Copyright (c) 2009 Matt Reid, Kontrollbase LLC
   * @license http://kontrollsoft.com/kontrollbase/userguide/general-LICENSE.php
   * @link http://kontrollbase.com
   */

class Agent extends Controller {

  function Agent()
  {
    parent::Controller();
  }

  function index() {	  
    log_message('debug', "agent::index function called");
    $this->load->view('index');
  }

  
  function report() {  
    $this->load->model('Model_agent', 'agent');
    log_message('debug', "agent_report function called");
   
    $g['data'] = $this->agent->get_access_report();
    $g['root'] = $this->config->item('base_url');
    $this->load->view('agent/accessreport',$g);
  }  

  function request() {
    log_message('debug', "agent:request:: function starting");
    $this->load->model('Model_agent', 'agent');
    $this->load->model('Model_main', 'main');
    $host_list_uuid = ($this->uri->segment(3))?$this->uri->segment(3):0;
    log_message('debug', "agent:request:: host_list_uuid: $host_list_uuid");
    
    if(!$host_list_uuid) {
      show_error("No UUID specified.");
      log_message('debug', "agent:request:: ERROR - no UUID specified");
    }
    else {
      $g['host'] = $this->main->get_host_by_uuid($host_list_uuid);
      $g['template'] = $this->agent->get_template_via_uuid($host_list_uuid);
      $g['root'] = $this->config->item('base_url');
      log_message('debug', "agent:request:: loading view");
      $this->agent->log_request_uuid($host_list_uuid);
      $this->load->view('agent/request',$g);
    }
  }

}

?>